package com.norbitltd.guavaleaves.java.lang;

import com.google.common.base.Predicate;

public class BytePredicates extends ObjectPredicates {

	/**
	 * Returns a predicate which checks whether the predicate argument is greater than a given byte value
	 * @param b Value to compare the predicate value with
	 * @return True if the predicate value is greater than b, false otherwise
	 */
	public static Predicate<Byte> isGreaterThan(final byte b) {
		return new Predicate<Byte>() {
			public boolean apply(Byte input) {
				return input != null && input > b;
			}
		};
	}

	/**
	 * Returns a predicate which checks whether the predicate argument is greater than or equal to a given byte value
	 * @param b Value to compare the predicate value with
	 * @return True if the predicate value is greater than or equal to b, false otherwise
	 */
	public static Predicate<Byte> isGreaterOrEqualThan(final byte b) {
		return new Predicate<Byte>() {
			public boolean apply(Byte input) {
				return input != null && input >= b;
			}
		};
	}

	/**
	 * Returns a predicate which checks whether the predicate argument is lower than a given byte value
	 * @param b Value to compare the predicate value with
	 * @return True if the predicate value is lower than b, false otherwise
	 */
	public static Predicate<Byte> isLowerThan(final byte b) {
		return new Predicate<Byte>() {
			public boolean apply(Byte input) {
				return input != null && input < b;
			}
		};
	}

	/**
	 * Returns a predicate which checks whether the predicate argument is lower that or equal to than a given byte value
	 * @param b Value to compare the predicate value with
	 * @return True if the predicate value is lower than or equal to b, false otherwise
	 */
	public static Predicate<Byte> isLowerOrEqualThan(final byte b) {
		return new Predicate<Byte>() {
			public boolean apply(Byte input) {
				return input != null && input <= b;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is equal to a given int value
	 * @param b Value to compare the predicate value with
	 * @return True if the predicate value is equal to b, false otherwise
	 */
	public static Predicate<Byte> isEqual(final byte b) {
		return new Predicate<Byte>() {
			public boolean apply(Byte input) {
				return input != null && input == b;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is not equal to a given int value
	 * @param b Value to compare the predicate value with
	 * @return True if the predicate value is not equal to b, false otherwise
	 */
	public static Predicate<Byte> isNotEqual(final byte b) {
		return new Predicate<Byte>() {
			public boolean apply(Byte input) {
				return input != null && input != b;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is a positive int value
	 * @return True if the predicate value is greater than 0, false otherwise
	 */
	public static Predicate<Byte> isPositive() {
		return new Predicate<Byte>() {
			public boolean apply(Byte input) {
				return input != null && input > 0;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is a negative int value
	 * @return True if the predicate value is lower than 0, false otherwise
	 */
	public static Predicate<Byte> isNegative() {
		return new Predicate<Byte>() {
			public boolean apply(Byte input) {
				return input != null && input < 0;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is a zero-valued int value
	 * @return True if the predicate value is equal 0, false otherwise
	 */
	public static Predicate<Byte> isZero() {
		return new Predicate<Byte>() {
			public boolean apply(Byte input) {
				return input != null && input == 0;
			}
		};
	}

	/**
	 * Returns a predicate which check whether the predicate argument is not a zero-valued int value
	 * @return True if the predicate value is not equal 0, false otherwise
	 */
	public static Predicate<Byte> isNotZero() {
		return new Predicate<Byte>() {
			public boolean apply(Byte input) {
				return input != null && input != 0;
			}
		};
	}
}
